The present invention relates to microprocessors and in particular to a method of time-sharing a microprocessor""s configurable I/O pins.
Microprocessors are provided with a number of terminal pins, some of which provide power to the microprocessor while others allow the microprocessor to communicate with other devices by receiving signals on input pins or sending signals on output pins. In a typical microprocessor, some pins are dedicated to particular input or output functions, while others can be selectively configured to perform either input or output functions. In either case, each I/O pin is associated with only one input or output device. With the complexity of electronic circuits today, it is not uncommon for an application to require more input and/or output pins than the microprocessor has available. One solution is to add additional interface adapters thereby increasing the number of available I/O pins. This solution adds additional components to the circuit, which, in turn, requires more space on the printed circuit board and increases cost. Another solution is to share configurable I/O pins by putting one input and one output device on a selected pin. This type of reconfiguration has required the disabling of both internal and external circuitry connected to the selected pin in one direction (input or output) while the other direction (output or input) is active. To accomplish this, two signals must be executed by the microprocessor. One signal disables the internal circuitry of the selected pin and one signal disables the external circuitry of the selected pin. This also requires the use of at least two microprocessor pins. One is the input pin that reads the status of the input device and the other is the pin through which the signal disabling the external circuit is sent. An example of this type of pin sharing is provided in the Microchip Technology, Inc., application note AN529, dated 1994, incorporated herein by reference, which describes a multiplexing LED drive and a 4xc3x974 keypad sampling. The particular application described by Microchip is well suited for multiplexing a number of input and output signals; however, it is not efficient for industrial control applications. FIG. 1 illustrates a simplified circuit diagram of the Microchip""s circuit 2A as it might be applied to industrial control applications. This circuit requires two output pins and one input pin to provide a pulsed output to one segment of the four 7-segment LED""s and to read the status of one of the 4xc3x974 keypad switches. This method of pin reconfiguration, although allowing more I/O functions for the number of I/O pins, is not the most efficient use of microprocessor I/O pins when used in other applications. Further, this circuit can not be used for I/O pin time-sharing when the output device requires a continuous control signal from the microprocessor. It would therefore be desirable to provide a circuit and method of pin reconfiguration that involves only the I/O pin that has been selected for reconfiguration. Such a method of reconfiguration would permit the I/O pin previously required for sending the external circuitry disable signal to be selectively reconfigured also. It would further be desirable that a single time-sharing circuit configuration be usable for output devices requiring a continuous signal from the output pin of the microprocessor and for output devices operable from a pulsed or periodically interrupted output signal.
The present invention provides a circuit for efficiently reconfiguring a microprocessor I/O pin for time-sharing between an input function and an output function. This circuit does not require the disabling of external circuitry or the use of additional microprocessor pins to accomplish the output-to-input reconfiguration and can be used with output devices requiring either a continuous or intermittent output signal. In this circuit, a pull-up resistor, a dropping resistor and an output device all have a common electrical connection at a terminal connected to the selected reconfigurable I/O pin of the microprocessor. The selected reconfigurable I/O pin of the microprocessor is normally configured as an output pin for controlling the output device. The other terminal of the pull-up resistor is connected to the regulated power source (Vcc) of the circuit and the other terminal of the dropping resistor is connected to an input device. The input device provides an input signal to the microprocessor in the form of a voltage, representing a logical state of either xe2x80x9c1xe2x80x9d or xe2x80x9c0xe2x80x9d, at the selected reconfigurable I/O pin. This signal is determined by the state (open or closed) of the input device, which is connected electrically between the dropping resistor and some point of the circuit at ground potential. The logical state of the input device can be observed by the microprocessor only when the selected reconfigurable I/O pin is configured for input. Therefore, the resistance values of the pull-up and dropping resistors must be selected such that a minimum resistance ratio is maintained between them. This resistance ratio permits one of two voltage levels representing the logical states of xe2x80x9c1xe2x80x9d or xe2x80x9c0xe2x80x9d to be present at the pin terminal when it is configured for input. The pull-up and dropping resistors must also have a minimum resistance value sufficiently high enough that the output signal from the selected I/O pin, when configured for output, can override the voltage value representing the logical state of the input device. This permits the I/O pin, normally configured for output, to maintain control over the associated output device regardless of the state of the input device. It is important that the type of output device connected to the selected I/O pin and the frequency of input change be considered when selecting output and input devices to share a particular I/O pin. An output device which can not tolerate periodic breaks in the output signal of the microprocessor should only share a pin with an input device providing an input signal which will not change after the initialization or start up period. Output devices which can tolerate insignificant periods of output signal loss can share an I/O pin with input devices which are expected to change logical states during normal operation. Therefore, the time or frequency at which the selected reconfigurable I/O pin can be reconfigured from output to input is dependent upon the type of output and input device selected to share the selected reconfigurable I/O pin.